package com.ace3l.legal.gwt.adminportal.client;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HorizontalPanel;

import com.gwtext.client.widgets.layout.FitLayout;
import com.gwtext.client.widgets.layout.TableLayout;
import com.gwtext.client.widgets.layout.TableLayoutData;
import com.gwtext.client.widgets.layout.VerticalLayout;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
import com.gwtext.client.widgets.Toolbar;
import com.gwtext.client.widgets.PaddedPanel;
import com.gwtext.client.widgets.ToolbarButton;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.form.Label;
import com.gwtext.client.core.EventObject;

/**
 * Created by IntelliJ IDEA.
 * User: ageer
 * Date: Jul 18, 2008
 * Time: 8:31:07 PM
 * To change this template use File | Settings | File Templates.
 */
public class AdminPortal extends Composite {
    Panel portalPanel = new Panel();
    Panel tablePanel = new Panel();

    Toolbar buttonBar = new Toolbar();
    ButtonListenerAdapter logoutEvent;


    Panel newStudentsPanel = new Panel();
    Panel newLawFirmsPanel = new Panel();
    Panel completedProjectsPanel = new Panel();
    Panel newProjectsPanel = new Panel();
    Panel activeProjectsPanel = new Panel();

    public AdminPortal(ButtonListenerAdapter logoutEvent) {
        this.logoutEvent = logoutEvent;

        newStudentsInit();
        newLawFirmsInit();
        completedProjectsInit();
        newProjectsInit();
        activeProjectsInit();

        toolbarInit();

        portalPanel.setBorder(true);
        portalPanel.setPaddings(10);
        portalPanel.setLayout(new FitLayout());
        portalPanel.setTopToolbar(buttonBar);

        tablePanel.setAutoScroll(true);
        tablePanel.setBorder(false);
        tablePanel.setLayout(new VerticalLayout(10));

        tablePanel.add(newProjectsPanel);
        tablePanel.add(completedProjectsPanel);
        tablePanel.add(newStudentsPanel);
        tablePanel.add(newLawFirmsPanel);
        tablePanel.add(activeProjectsPanel);

        portalPanel.add(tablePanel);


        initWidget(portalPanel);
    }
    private void newStudentsInit() {
        newStudentsPanel.setWidth(938);
        newStudentsPanel.setFrame(true);
        newStudentsPanel.setTitle("Recently Created Students");
        newStudentsPanel.setCollapsible(true);
        newStudentsPanel.setAnimCollapse(true);
        Label myLabel = new Label("Recently Created Students Portlet");
        newStudentsPanel.add(myLabel);
    }
    private void newLawFirmsInit() {
        newLawFirmsPanel.setWidth(938);
        newLawFirmsPanel.setFrame(true);
        newLawFirmsPanel.setTitle("Recently Created LawFirms");
        newLawFirmsPanel.setCollapsible(true);
        newLawFirmsPanel.setAnimCollapse(true);
        Label myLabel = new Label("Recently Created Law Firms Portlet");
        newLawFirmsPanel.add(myLabel);
    }
    private void completedProjectsInit() {
        completedProjectsPanel.setWidth(938);
        completedProjectsPanel.setFrame(true);
        completedProjectsPanel.setTitle("Recently Completed Projects");
        completedProjectsPanel.setCollapsible(true);
        completedProjectsPanel.setAnimCollapse(true);
        Label myLabel = new Label("Recently Completed Projects Portlet");
        completedProjectsPanel.add(myLabel);
    }

    private void newProjectsInit() {
        newProjectsPanel.setWidth(938);
        newProjectsPanel.setFrame(true);
        newProjectsPanel.setTitle("Recently Created Projects");
        newProjectsPanel.setCollapsible(true);
        newProjectsPanel.setAnimCollapse(true);
        Label myLabel = new Label("Recently Created Projects Portlet");
        newProjectsPanel.add(myLabel);
    }

    private void activeProjectsInit() {
        activeProjectsPanel.setWidth(938);
        activeProjectsPanel.setHeight("auto");
        activeProjectsPanel.setFrame(true);
        activeProjectsPanel.setTitle("Currently Active Projects");
        activeProjectsPanel.setCollapsible(true);
        activeProjectsPanel.setAnimCollapse(true);
        Label myLabel = new Label("Active Projects Panel");
        activeProjectsPanel.add(myLabel);
    }

    private void toolbarInit() {
        ToolbarButton reports = new ToolbarButton("Reports", new ButtonListenerAdapter() {
            public void onClick(com.gwtext.client.widgets.Button button, EventObject eventObject) {

            }
        });
        ToolbarButton users = new ToolbarButton("Users", new ButtonListenerAdapter() {
            public void onClick(com.gwtext.client.widgets.Button button, EventObject eventObject) {

            }
        });
        ToolbarButton projects = new ToolbarButton("Projects", new ButtonListenerAdapter() {
            public void onClick(com.gwtext.client.widgets.Button button, EventObject eventObject) {

            }
        });
        ToolbarButton news = new ToolbarButton("News", new ButtonListenerAdapter() {
            public void onClick(com.gwtext.client.widgets.Button button, EventObject eventObject) {

            }
        });
        ToolbarButton notifications = new ToolbarButton("Notifications", new ButtonListenerAdapter() {
            public void onClick(com.gwtext.client.widgets.Button button, EventObject eventObject) {

            }
        });
        ToolbarButton logout = new ToolbarButton("Logout", logoutEvent);
        buttonBar.addText("Welcome Fancy Law Firm");
        buttonBar.addFill();
        buttonBar.addButton(reports);
        buttonBar.addSeparator();
        buttonBar.addButton(users);
        buttonBar.addSeparator();
        buttonBar.addButton(projects);
        buttonBar.addSeparator();
        buttonBar.addButton(news);
        buttonBar.addSeparator();
        buttonBar.addButton(notifications);
        buttonBar.addSeparator();
        buttonBar.addButton(logout);

    }

    
}
